package com.wontube.smr.pub;

import java.util.ArrayList;

import com.wontube.smr.model.vo.Progress;




/**
 * @author yuechao
 *
 */
public final class SyncObject {
	private int useCount = 0;
	
	// 监听者
	private ArrayList<IObjectListener<Progress>> listeners = new ArrayList<IObjectListener<Progress>>();

	public int getUseCount() {
		return this.useCount;
	}

	public void increase() {
		this.useCount++;
	}
	
	public void decrease() {
		this.useCount--;
	}
	
	public ArrayList<IObjectListener<Progress>> getListeners() {
		return this.listeners;
	}

	public void onProgress(Progress progress) {
		for (IObjectListener<Progress> listener : this.listeners) {
			listener.onMessage(progress);
		}
	}
	
	public void onError(String msg) {
		for (IObjectListener<Progress> listener : listeners) {
			listener.onError(msg);
		}
	}
}